<template>
  <div>
    <!-- <navbar></navbar> -->
    <!-- 患者信息 -->
    <div style="height: 40px; margin-top: 10px">
      <el-row>
        <el-col :span="2">
          <div class="grid-content">
            <i class="el-icon-user"></i>01 床 杜某 |
          </div>
        </el-col>
        <el-col :span="2">
          <div class="grid-content">床号：01</div>
        </el-col>
        <el-col :span="2">
          <div class="grid-content">姓名：杜某</div>
        </el-col>
        <el-col :span="2">
          <div class="grid-content">性别：男</div>
        </el-col>
        <el-col :span="2">
          <div class="grid-content">年龄：21岁</div>
        </el-col>
        <el-col :span="4">
          <div class="grid-content">入院日期:2022-04-21 13:14</div>
        </el-col>
        <el-button size="medium" type="primary" style="float: right" @click="ToNursingProblems()">前往护理问题</el-button
        >
      </el-row>
    </div>

    <!-- 整体评估、专项评估 -->
    <el-tabs v-model="activeName" @tab-click="handleClick" stretch type="border-card">
      <el-tab-pane label="整体评估" name="first">
        <overall-evaluation />
      </el-tab-pane>
      <el-tab-pane label="专项评估" name="second">
        <special-evaluation />
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import overallEvaluation from "./overallEvaluation/overallEvaluation.vue";
import specialEvaluation from "./specialEvaluation/specialEvaluation.vue";
import { getNursingProblems } from "@/api/overallEva";

var BaaS = require("minapp-sdk");
let clientID = "9ed0a3da89683e42d793";
BaaS.init(clientID);

export default {
  name: "Evaluation",
  components: {
    overallEvaluation,
    specialEvaluation,
  },
  data() {
    return {
      activeName: "first",
      patient_id: "1001",
      result:
        '{"d.A.1":0,"d.A.2":0,"d.A.3":0,"d.A.4":0,"d.A.5":0,"d.A.6":0,"d.A.7":0,"d.A.8":0,"d.A.9":0,"d.B.1":0,"d.B.2":0,"d.B.3":0,"d.B.4":0,"d.B.5":0,"d.B.6":0,"d.B.7":0,"d.B.8":0,"d.B.9":0,"d.C.1":0,"d.C.2":0,"d.C.3":0,"d.C.4":0,"d.D.1":0,"d.D.2":0,"d.D.3":0,"d.D.4":0,"d.D.5":0,"d.D.6":0,"d.D.7":0,"d.D.8":0,"d.D.9":0,"d.D.10":0,"d.D.11":0,"d.D.12":0,"d.E.1":0,"d.E.2":0,"d.E.3":1,"d.E.4":0,"d.E.5":0,"d.E.6":0,"d.E.7":0,"d.E.8":0,"d.E.9":0,"d.E.10":0,"d.E.11":0,"d.E.12":0,"d.E.13":0,"d.E.14":0,"d.E.15":0,"d.E.16":0,"d.F.1":0,"d.F.2":0,"d.F.3":0,"d.F.4":0,"d.F.5":0,"d.F.6":0,"d.G.1":0,"d.G.2":0,"d.G.3":0,"d.G.4":0,"d.G.5":0,"d.G.6":0,"d.G.7":0,"d.G.8":0,"d.G.9":0,"d.G.10":0,"d.G.11":0,"d.H.1":0,"d.H.2":0,"d.I.1":0,"d.I.2":0,"d.J.1":0,"d.J.2":0,"d.J.3":0,"d.J.4":0,"d.J.5":0,"d.J.6":0,"d.J.7":0,"d.J.8":0,"d.K.1":0,"d.K.2":1,"d.K.3":1,"d.K.4":0,"d.K.5":1,"d.K.6":0,"d.K.7":0,"d.K.8":0,"d.L.1":0,"d.L.2":0,"d.L.3":0,"d.L.4":0,"d.L.5":0,"d.M.1":0,"d.M.2":0,"d.M.3":0,"d.M.4":0,"d.M.5":0,"d.M.6":0,"d.M.7":0,"d.M.8":0,"d.M.9":0,"d.M.10":0,"d.M.11":0,"d.M.12":0,"d.M.13":0,"d.N.1":0,"d.N.2":0,"d.N.3":0,"d.N.4":0,"d.N.5":0,"d.N.6":0,"d.N.7":0,"d.N.8":0,"d.N.9":0,"d.N.10":0,"d.N.11":0,"d.N.12":0,"d.N.13":0,"d.N.14":0,"d.N.15":0,"d.N.16":0,"d.N.17":0,"d.O.1":0,"d.O.2":0,"d.O.3":0,"d.O.4":0,"d.O.5":0,"d.O.6":0,"d.O.7":0,"d.P.1":0,"d.P.2":0,"d.P.3":0,"d.P.4":0,"d.P.5":0,"d.P.6":0,"d.P.7":0,"d.P.8":0,"d.P.9":0,"d.P.10":0,"d.Q.1":0,"d.Q.2":0,"d.Q.3":0,"d.Q.4":0,"d.Q.5":0,"d.Q.6":0,"d.Q.7":0,"d.Q.8":0,"d.Q.9":0,"d.Q.10":0,"d.Q.11":0,"d.Q.12":0,"d.R.1":0,"d.R.2":1,"d.R.3":0,"d.R.4":0,"d.R.5":0,"d.R.6":0,"d.R.7":0,"d.S.1":0,"d.T.1":0,"d.T.2":0,"d.T.3":0,"d.T.4":0,"d.T.5":0,"d.T.6":0,"d.T.7":0,"d.U.1":0,"d.U.2":0,"d.U.3":0,"d.U.4":0,"d.U.5":0,"d.U.6":0,"d.U.7":0,"d.U.8":0,"d.U.9":0,"d.U.10":0}',
    };
  },
  methods: {
    handleClick(tab, event) {
      console.log(tab, event);
    },
    getNursingProblemsList(index) {
      let data = {}
      let query = new BaaS.Query();
      let patient_nursing = new BaaS.TableObject("patient_nursing");
      query.compare('patient_id', '=', this.patient_id);
      patient_nursing
        .setQuery(query)
        .select([
          "eva_overall",
          "eva_spec",
        ])
        .limit(1000)
        .offset(index)
        .find()
        .then((res) => {
          data  = res.data.objects[0]; // 包含整体评估和专项评估的对象
          console.log(data);
        });
      return this.result;
      //这里调用api接口，但是之后会修改
      // getNursingProblems(data).then((res) => {
      //   console.log(res);
      //   return res;
      // })
      // .catch((err) => {
      //   console.log(err);
      // });
    },

    ToNursingProblems() {
      // 需要先判断提醒一下

      //获取护理问题
      let nursingProblems = this.getNursingProblemsList(0);
      //修改路由
      this.$router.push({
        path: "/nursingProblems", //要跳转的页面的路径
        name: "nursingProblems", //要跳转页面的name 在router index.js保持一致
        params: {
          patientId: this.patient_id, //这里是要传入的参数 （评估结果）
          nursingProblems: nursingProblems,
        },
      });
    },
  },
};
</script>

<style lang="less" scoped>
:deep(.el-tabs--border-card > .el-tabs__header .el-tabs__item.is-active) {
  color: #ffffff;
  background-color: #079599;
  border-right-color: #dcdfe6;
  border-left-color: #dcdfe6;
}
</style>